import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from "vuex-persistedstate";
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
	baseImgURL:'https://webedu.starfishedu.cn/picture/static', 
	baseURL:'https://webedu.starfishedu.cn',
	currentMenu:'home', // 当前在哪个菜单
	deviceId:'3566S-2C3-A1C68', // 设备唯一号
	userInfo:{
		currentMode:'1',   //1-班牌模式 2-欢迎模式 3-考试模式
		status:'1'   // 状态 0-关机 1-运行 2-待机
	}, 
	
	powerTime:{
		startT:null, //开机时间
		eduT:null,  // 关机时间
	},
    classId:'', // 班级id
	schoolId:''  //学校id
	
  },

  mutations: {
	
	updateDevice(state,payload){
		state.deviceId = payload;
	 },
	setPowerTime(state,payload){
		state.powerTime = {
			startT:payload.startT,
			eduT:payload.eduT
		}
	 },
	 
	setSlassID(state,classId){
      state.classId = classId
    },  
	setSchoolId(state,payload){
      state.schoolId = payload
    },
	updateCurrentMenu(state,payload){
		state.currentMenu = payload;
	},
	setUserInfo(state,payload){	
		state.userInfo = {...state.userInfo,...payload};
	},
  },
   /* vuex数据持久化配置 */
      plugins: [createPersistedState({
             storage: {
                 getItem: (key) => uni.getStorageSync(key),
                 setItem: (key, value) => uni.setStorageSync(key,value),
                 removeItem: key => uni.removeStorageSync(key)
				 }
		})]
})
